home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
programr
/
rtx2000.zip
/
rtx2000
/
fctest
next >
Wrap
Text File
|
1993-09-01
|
10KB
|
451 lines
( This is a test file for the fc compiler which demonstrates code production and
optimization -- it is not an actual running program )
( Compare the .lst file obtained from compiling this file using the -l option
with this source file to see how code is produced )
(Throughout the file, commas are used to cause immeadate code production.
This causes the compiler to stop looking for more instructions to combine into
the machine code currently being produced. )
( Note that there are several types of constants used
a: short positive constants 0 to 31
b: short negative constants -32 to -1
c: long constants (all other sixteen bit numbers)
)
: shift_test
( Each of 15 shift instructions )
0<
2*
2*c
cU2/
c2/
U2/
2/
N2*
N2*c
D2*
D2*c
cUD2/
cD2/
UD2/
D2/
nop
;
: alu_ops
( alu operations )
and
swap and
-
swap -
or
swap or
+
swap +
xor
swap xor
nor
swap nor
-c
swap -c
nand
swap nand
+c
swap +c
xnor
swap xnor
nop
;
: invert_shift_optional
(following instructions can be combined together with a "not" and/or shift )
(the shift and constants used are arbitrary )
drop dup ( 16 bits )
drop dup 2*
drop dup not
drop dup not 2*
swap drop ( 16 bits )
swap drop 2*
swap drop not
swap drop not 2*
drop ( 16 bits )
drop 2*
drop not
drop not 2*
swap drop dup ( 16 bits )
swap drop dup 2*
swap drop dup not
swap drop dup not 2*
swap , ( 16 bits )
swap 2*
swap not
swap not 2*
dup ( 16 bits )
dup 2*
dup not
dup not 2*
over , ( 16 bits )
over 2*
over not
over not 2*
over over ( 32 bits )
over over 2*
over over not
over over not 2*
over swap ( 32 bits )
over swap 2*
over swap not
over swap not 2*
swap over ( 32 bits )
swap over 2*
swap over not
swap over not 2*
0x15 g@ over ( 32 bits )
0x15 g@ over 2*
0x15 g@ over not
0x15 g@ over not 2*
0x15 over ( 32 bits )
0x15 over 2*
0x15 over not
0x15 over not 2*
0x15 swap ( 32 bits )
0x15 swap 2*
0x15 swap not
0x15 swap not 2*
-1 swap ( 32 bits )
-1 swap 2*
-1 swap not
-1 swap not 2*
0x15 u@ over ( 32 bits )
0x15 u@ over 2*
0x15 u@ over not
0x15 u@ over not 2*
@ over ( 32 bits )
@ over 2*
@ over not
@ over not 2*
c@ over ( 32 bits )
c@ over 2*
c@ over not
c@ over not 2*
0x5555 over ( 48 bits )
0x5555 over 2*
0x5555 over not
0x5555 over not 2*
nop
;
: shift_optional
(these instructions can be combined with a shift )
(the shift and alu op are arbitrary )
over over - ( 16 bits )
over over - 2/
over - ( 16 bits )
over - 2/
- ( 16 bits )
- 2/
swap over - ( 16 bits )
swap over - 2/
not ( 16 bits )
not 2/
nop
;
: invert_optional
(these instuctions can be combined with a "not" )
(constants are arbitrary )
0x15 ( 16 bits - short positive constant )
0x15 not
-10 ( 16 bits - short negative constant )
-10 not
0x15 swap drop ( 16 bits )
0x15 swap drop not
-10 swap drop ( 16 bits )
-10 swap drop not
drop 0x15 ( 16 bits )
drop 0x15 not
drop -10 ( 16 bits )
drop -10 not
dup 0x15 ( 32 bits )
dup 0x15 not
0x15 u@ swap ( 16 bits )
0x15 u@ swap not
0x15 u@ ( 16 bits )
0x15 u@ not
dup 0x15 u@ ( 32 bits )
dup 0x15 u@ not
dup 0x15 u! ( 16 bits )
dup 0x15 u! not
0x15 u! ( 16 bits )
0x15 u! not
@ swap ( 16 bits )
@ swap not
c@ swap ( 16 bits )
c@ swap not
@ ( 16 bits )
@ not
c@ ( 16 bits )
c@ not
dup @ ( 32 bits )
dup @ not
dup c@ ( 32 bits )
dup c@ not
dup @ swap 0x15 ( 32 bits )
dup @ swap 0x15 not
dup c@ swap 0x15 ( 32 bits )
dup c@ swap 0x15 not
swap drop @ ( 32 bits )
swap drop @ not
swap drop c@ ( 32 bits )
swap drop c@ not
swap drop dup @ , ( 32 bits )
swap drop dup @ not
swap drop dup c@ , ( 32 bits )
swap drop dup c@ not
swap drop dup @ swap 0x15 ( 32 bits )
swap drop dup @ swap 0x15 not
swap drop dup c@ swap 0x15 ( 32 bits )
swap drop dup c@ swap 0x15 not
over swap ! ( 16 bits )
over swap ! not
over swap c! ( 16 bits )
over swap c! not
swap over ! 0x15 ( 32 bits )
swap over ! 0x15 not
swap over c! 0x15 ( 32 bits )
swap over c! 0x15 not
over over ! 0x15 ( 32 bits )
over over ! 0x15 not
over over c! 0x15 ( 32 bits )
over over c! 0x15 not
! ( 16 bits )
! not
c! ( 16 bits )
c! not
nop
;
: terminal
(these instructions can not be combined with any more instructions )
0x15 over - ( 16 bits )
dup 0x15 - ( 16 bits )
0x15 - ( 16 bits )
0x15 u@ over - ( 16 bits )
dup 0x15 u@ - ( 16 bits )
0x15 u@ - ( 16 bits )
@ over - ( 16 bits )
c@ over - ( 16 bits )
dup @ swap ( 16 bits )
dup c@ swap , ( 16 bits )
swap drop dup @ swap , ( 16 bits )
swap drop dup c@ swap ( 16 bits )
@ 0x15 ( 16 bits )
c@ 0x15 ( 16 bits )
swap drop @ 0x15 ( 16 bits )
swap drop c@ 0x15 ( 16 bits )
dup @ swap 0x15 - ( 16 bits )
dup c@ swap 0x15 - ( 16 bits )
swap drop dup @ swap 0x15 - ( 16 bits )
swap drop dup c@ swap 0x15 - ( 16 bits )
@+ ( 16 bits )
c@+ ( 16 bits )
@- ( 16 bits )
c@- ( 16 bits )
swap drop @+ ( 16 bits )
swap drop c@+ ( 16 bits )
swap drop @- ( 16 bits )
swap drop c@- ( 16 bits )
@ - ( 16 bits )
c@ - ( 16 bits )
swap over ! ( 16 bits )
swap over c! ( 16 bits )
over over ! ( 16 bits )
over over c! ( 16 bits )
! 0x15 ( 16 bits )
c! 0x15 ( 16 bits )
over swap ! 0x15 ( 16 bits )
over swap c! 0x15 ( 16 bits )
!+ ( 16 bits )
c!+ ( 16 bits )
!- ( 16 bits )
c!- ( 16 bits )
over swap !+ ( 16 bits )
over swap c!+ ( 16 bits )
over swap !- ( 16 bits )
over swap c!- ( 16 bits )
swap over ! 0x15 - ( 16 bits )
swap over c! 0x15 - ( 16 bits )
over over ! 0x15 - ( 16 bits )
over over c! 0x15 - ( 16 bits )
nop
;
: g_types
( these instructions allow access of the ASIC bus )
0x15 g@ drop ( 16 bits )
0x15 g@ drop not
0x15 g@ ( 16 bits )
0x15 g@ not
dup 0x15 g@ ( 32 bits )
dup 0x15 g@ not
dup 0x15 g! ( 16 bits )
dup 0x15 g! not
0x15 g! ( 16 bits )
0x15 g! not
0x15 g@ over - ( 16 bits )
dup 0x15 g@ - ( 16 bits )
0x15 g@ - ( 16 bits )
nop
;
: long_constants
(these are instructions for loading long constants onto the stack )
0x5555 swap ( 32 bits )
0x5555 swap not
0x5555 ( 32 bits )
0x5555 not
0x5555 swap drop ( 32 bits )
0x5555 swap drop not
drop 0x5555 ( 32 bits )
drop 0x5555 not
dup 0x5555 ( 48 bits )
dup 0x5555 not
0x5555 - ( 32 bits )
dup 0x5555 - ( 32 bits )
0x5555 over - ( 32 bits )
(Strings )
"test" ( varies with length of string )
"test" not
(Tick)
['] alu_ops ( 32 bits )
['] alu_ops not
['] test4 ( 32 bits )
['] test4 not
nop
;
(Return coding)
: test2 exit exit exit ;
: test3 not ;
: test4 1 ;
: test5 0 g@ exit 1 g@ exit 2 g@ ;
: test6 0 g! exit 1 g! exit 2 g! ;
: test7 3 g@ exit 3 g! exit 4 g@ ;
: test8 0x5555 exit 0x5555 ;
(swaps)
: test9 swap swap swap swap swap ;
(0x3f0 code ( if nexting ))
: test10
if
if
if
if
if
if
if
if
if nop else
nop then
else nop
then if nop then
then
then
then
then
then
then
then ;
(0x3f0 code (for next nesting))
: test12
for
for
for
for
for
for
for
for
for
nop
next
next
next
next
next
next
next
next
next ;
( Note with word tables any undefined labels are assummed to be words )
word table1 { test2 test3 test4 0 1 2 3 -1 -2 -3 test11 }
byte table2 { 1 2 3 4 5 6 7 }
word table3 { table1 table2 table3 }
: test11
( demo of looping features )
begin
begin
begin
begin
begin
begin
begin
again
again
again
again
again
again
again
begin
begin
begin
begin
begin
begin
begin
until
until
until
until
until
until
until
begin
begin
begin
begin
begin
begin
begin
while
repeat
while
repeat
while
repeat
while
repeat
while
repeat
while
repeat
while
repeat
nop
;